import { getCategoryAPI } from "@/apis/layout";
import { HomeCategoryType } from "@/types/category";
import { defineStore } from "pinia";
import { ref } from "vue";

export const useCategoryStore = defineStore('category', () => {
    // 数据分类列表
    const categoryList = ref<Array<HomeCategoryType>>([]);

    // 获取数据分类列表的方法
    const getCategory = async () => {
        const response = await getCategoryAPI();
        // 添加新数据分类列表
        categoryList.value = response.data.result;
    };

    return { categoryList, getCategory };
});